home *** CD-ROM | disk | FTP | other *** search
/ Hráč 2005 January / Hrac_76_2005-01_dvd.iso / lokalizacie / Medal Of Honor Allied Assault / mohaa10cz.exe / {app} / main / Pak10.pk3 / Global / vehicles_thinkers.scr < prev   
Text File  |  2002-03-23  |  24KB  |  948 lines

  1. //*******************************
  2. players_tank local.trigger:
  3. //    self vehiclespeed 300
  4.     self rendereffects "-shadow"
  5.     local.parent = spawn script_origin
  6.     local.parent.origin = self.origin
  7.     level.playertanktarget = spawn script_origin
  8.     level.playertanktarget.origin = (self.origin + (0 0 80))
  9.     level.playertanktarget bind local.parent
  10.     local.parent glue self
  11.  
  12.         
  13.     self removeondeath 0
  14.     if (self.target)
  15.     {
  16.         self.collisionent = self.target
  17.     //    self.collisionent hide
  18.     }    
  19.     local.gun = self QueryTurretSlotEntity 0
  20.     local.gun2 = self QueryTurretSlotEntity 1
  21.     if (local.gun)
  22.         local.gun nodamage
  23.     if (local.gun2)
  24.         local.gun2 nodamage
  25.  
  26.     thread player_tank_health
  27. end
  28.  
  29. player_tank_health:
  30.     level waittill prespawn
  31.     
  32.     
  33.     if (getcvar(debug) != "1")
  34.     {
  35.         $player notsolid
  36.         $player nodamage
  37.         self attachdriverslot 0 $player
  38.         $player perferredweapon "88mm Tank Gun"
  39.     }
  40.  
  41.     level waittill spawn
  42.     
  43.     local.skill = getcvar (skill)
  44.     println "z:       local.skill = getcvar (skill) = " local.skill   
  45.     
  46.     if (local.skill == "2")
  47.     {
  48.         println "z:         skill = 2 health = 1000"
  49.         self.health = 1000
  50.     }
  51.     if (local.skill == "1")
  52.     {
  53.         println "z:         skill = 1 health = 3000"
  54.         self.health = 3000
  55.     }
  56.     if ( (local.skill != "1") && (local.skill != "2") )
  57.     {
  58.         println "z:         skill != 2 and skill != 1 health = 5000"
  59.         self.health = 5000
  60.     }
  61.  
  62.  
  63. //        if ( (int (getcvar developer)) )
  64. //            thread playertank_health_hud
  65.         thread playertank_pain
  66.  
  67.  
  68.  
  69.     self waittill death
  70.  
  71.         self LockMovement
  72.         self playsound explode_tank
  73.         level.missionfailed = 1
  74.         iprintlnbold "Tank King Tiger byl ztracen.Misi jsi nesplnil."
  75.         //wait 3
  76.         missionfailed
  77.     end
  78.  
  79. playertank_pain:
  80.         local.original_health = self.health
  81.         local.previoushealth = self.health
  82.         local.paintime = level.time
  83.     
  84.         while(isAlive self)
  85.         {
  86.             wait .1
  87.             if (self.health < local.previoushealth)
  88.             {
  89.                 self playsound damage_tank
  90.                 exec global/earthquake.scr .2 4 0 0    
  91.         
  92.                 if ( (self.health < (local.previoushealth - 150)) && (level.time > (local.paintime + 5) ) )
  93.                 {
  94.                     local.paintime = level.time
  95.                     local.health_fraction = (self.health / local.original_health)
  96.                     println "z:     local.health_fraction: " local.health_fraction
  97.                     
  98.                     if (local.health_fraction >= 0.7)
  99.                     {
  100.                         $player playsound tank_hurt1
  101.                     }
  102.                     else if (local.health_fraction >= 0.4)
  103.                     {
  104.                         $player playsound tank_hurt2
  105.                     }
  106.                     else
  107.                     {
  108.                         $player playsound tank_hurt3
  109.                     }
  110.                 }
  111.                 
  112.                 local.previoushealth = self.health
  113.             }
  114.         }
  115.     end
  116.  
  117.  
  118. playertank_health_hud:
  119.         level.subtitleX = 100
  120.         level.subtitleY = 70
  121.         while ( 1)
  122.         {
  123.             locprint level.subtitleX level.subtitleY ("Zdravi: " + self.health)
  124.             wait 1
  125.         }
  126.     end
  127.  
  128.  
  129. //*****************************************
  130. PLAYER_JEEP_CONTROLLER local.trigger:
  131.     self vehicleanim remove_surfaces
  132.     self rendereffects "-shadow"
  133.     self thread speed_controls
  134.     self.driver rendereffects "-shadow"
  135.     self AttachDriverSlot 0 $oss_man
  136.     $oss_man exec global/disable_ai.scr
  137.     $oss_man anim jeep_idle_drive
  138.     $oss_man nodamage
  139.     $oss_man notsolid
  140.     $oss_man gun "none"
  141.     $oss_man immune bullet
  142.     $oss_man immune fast_bullet
  143.     $oss_man immune explosion
  144.     $oss_man immune rocket
  145.     $oss_man.gren_awareness = 0
  146.     $oss_man forceactivate
  147.     self nodamage
  148.     if (self.target)
  149.     {
  150.         self.collisionent = self.target
  151.     //    self.collisionent hide
  152.     }
  153.  
  154.     //local.trigger waittill trigger
  155.     
  156.     if (getcvar(debug) != "1")
  157.     {
  158.         local.vturretent = self queryturretslotentity 0
  159.         local.vturretent unlock
  160.         self attachturretslot 0 $player    // Attach the player to the jeep
  161.         $player perferredweapon ".30cal Machine Gun"
  162.         local.vturretent lock
  163.     }
  164.     
  165. //level waittill spawn
  166.  
  167.  
  168. //    if ( (int (getcvar developer)) )
  169. //        thread speed_tracker
  170. end
  171.  
  172.  
  173. speed_tracker:
  174.         level.subtitleX = 100
  175.         level.subtitleY = 70
  176.         while ( 1)
  177.         {
  178.             local.speed = vector_length(self.velocity)
  179.             local.message = ("speed: " + local.speed)
  180.             locprint level.subtitleX level.subtitleY local.message
  181.             wait .5
  182.         }
  183.     end
  184.  
  185. speed_controls:
  186.         for ( local.i = 1; local.i <= $slowdown.size; local.i++)
  187.         {
  188.             thread slowdown local.i
  189.         }
  190.         for ( local.i = 1; local.i <= $speedup.size; local.i++)
  191.         {
  192.             thread speedup local.i
  193.         }
  194.     end
  195.  
  196. speedup local.i:
  197.         while (1)
  198.         {
  199.             if ($speedup[local.i].speed != NIL)
  200.                 local.speed = $speedup[local.i].speed
  201.             else 
  202.                 local.speed = level.fastspeed
  203.     
  204.             println "z:      wait for trigger speedup: " local.i  " value " local.speed
  205.             $speedup[local.i] waittill trigger
  206.     
  207.             println "z:      modify drive speedup: " local.i  " value " local.speed
  208.             self.driver anim jeep_drive_gearchange_up
  209.             self modifydrive local.speed 10 level.lookahead
  210.             self.driver waittill animdone
  211.             self.driver anim jeep_idle_drive
  212.         }
  213.     end
  214.  
  215. slowdown local.i:
  216.         while (1)
  217.         {
  218.             if ($slowdown[local.i].speed != NIL)
  219.                 local.speed = $slowdown[local.i].speed
  220.             else 
  221.                 local.speed = level.slowspeed
  222.  
  223.             println "z:      wait for trigger slowdown: " local.i  " value " local.speed
  224.             $slowdown[local.i] waittill trigger
  225.     
  226.             println "z:      modify drive slowdown: " local.i  " value " local.speed
  227.             self.driver anim jeep_drive_gearchange_down
  228.             self modifydrive local.speed 40 level.lookahead
  229.             self.driver waittill animdone
  230.             self.driver anim jeep_idle_drive
  231.         }
  232.     end
  233.  
  234.  
  235.  
  236.  
  237.  
  238. //****************************************
  239. enemy_truck_think local.hp local.passengers local.path local.trigger local.type local.guy_type local.special:
  240.     self rendereffects "-shadow"
  241.     if (local.hp == NIL)
  242.         self.health = 4000
  243.     else 
  244.         self.health = local.hp
  245.     println "truck health: " self.health
  246.     thread truck_INIT
  247.         
  248.     if ( (local.passengers != NIL) && (local.passengers != 0) )
  249.         waitthread truck_load local.passengers local.guy_type local.panzer
  250.     if (local.path)
  251.     {
  252.         println "truck_drive thread initialized"
  253.         thread truck_drive local.path local.trigger
  254.     }
  255.     
  256. self waittill death
  257.  
  258.     self stop
  259.     self.collisionent disconnect_paths
  260.     thread truck_killed local.type
  261. end
  262.  
  263. truck_drive local.path local.trigger:
  264. if (local.trigger)
  265. {
  266.     println "truck waitting for trigger before driving"
  267.     local.trigger waittill trigger
  268. }
  269.  
  270.     local.speed = 200
  271.     local.accel = 50
  272.     local.lookahead = 256
  273.  
  274.     println "truck starting to drive"
  275.     self drive local.path local.speed local.accel 200 local.lookahead
  276.     self waitTill drive
  277.     self.drive_done = 1
  278.     self.collisionent disconnect_paths
  279.     println "truck done with waittill drive"
  280.     self stop
  281.     
  282.     wait 3
  283.     println "truck starting to unload"
  284.     thread truck_unload
  285. end
  286.  
  287. truck_load local.passengers local.guy_type local.special:
  288.     for (local.slot = 1; local.slot <= local.passengers; local.slot++)
  289.     {
  290.         if (local.guy_type == NIL)
  291.             local.guy_type = "models/human/german_afrika_private"        
  292.         if (randomint (3) == 1) 
  293.             local.gun = "MP40"
  294.         else
  295.             local.gun = "Mauser KAR 98K"
  296.         if ( (local.special == "panzer") && (local.slot == 1) )
  297.             local.gun = "panzerschrek"
  298.         local.guy = spawn local.guy_type "gun" local.gun
  299.         local.guy.origin = self.origin
  300.         local.guy rendereffects "-shadow"
  301.         if (level.dontdropweapons == 1)
  302.             local.guy dontdropweapons
  303.         self AttachPassengerSlot local.slot local.guy
  304.         local.guy type_attack "cover"
  305.         local.guy leash 0
  306.         //local.guy exec global/disable_ai.scr //temp
  307.         local.guy fixedleash 1
  308.         local.guy physics_off
  309.         
  310.         switch (local.slot)
  311.         {
  312.         case 1:
  313.             local.guy exec global/setdeathanim.scr "death_headpistol"
  314.             break
  315.         case 2:
  316.             local.guy exec global/setdeathanim.scr "death_crotch"
  317.             break
  318.         case 3:
  319.             local.guy exec global/setdeathanim.scr "death_left"
  320.             break
  321.         case 4:
  322.             local.guy exec global/setdeathanim.scr "death_run"
  323.             break
  324.         case 5:
  325.             local.guy exec global/setdeathanim.scr "death_shoot"
  326.             break
  327.         case 6:
  328.             local.guy exec global/setdeathanim.scr "death_right"
  329.             break
  330.         default:
  331.             local.guy exec global/setdeathanim.scr "death_collapse"
  332.             break
  333.         }
  334.         
  335.         
  336.         
  337.     }
  338.     //driving anim name = opel_driver    
  339.     local.driver = spawn local.guy_type "gun" "none"
  340.     local.driver.origin = self.origin
  341.     local.driver rendereffects "-shadow"
  342.     self AttachDriverSlot 0 local.driver
  343.     local.driver exec global/disable_ai.scr
  344.     local.driver anim opel_driver
  345.     self.driver = local.driver
  346.     local.driver exec global/setdeathanim.scr "opel_driver_death"
  347. end
  348.  
  349. truck_unload:
  350.     for (local.slot = 0; local.slot <= 6; local.slot++)
  351.     {
  352.         thread truck_passenger_unload local.slot
  353.     }
  354.     local.driver = self.driver
  355. //    self DetachDriverSlot 0 local.driver.origin
  356. //    local.driver.origin = self gettagposition "driver"
  357. //    local.driver.angles = self gettagangles "driver"
  358. //    local.driver physics_on
  359.     local.driver exec global/bullethit.scr (0 0 250) 500 0 1
  360.     self.done_unloading = 1
  361. end
  362.  
  363. truck_passenger_unload local.slot:
  364.     local.ent = self QueryPassengerSlotEntity local.slot
  365.     if !(isAlive local.ent)
  366.         end
  367.     if (local.ent == NULL)
  368.         end
  369.     local.ent exec global/disable_ai.scr
  370.     self DetachPassengerSlot local.slot local.ent.origin
  371.     local.tag = ("passenger" + local.slot)
  372.     println "z:      local.tag: " local.tag
  373.     local.ent.origin = self gettagposition local.tag
  374.     local.ent.angles = self gettagangles local.tag
  375.     local.ent notsolid
  376.     local.ent physics_on
  377.     local.ent anim_noclip ("opel_passenger" + local.slot)
  378.     local.ent waittill animdone
  379.     local.ent solid
  380.     local.ent rendereffects "+shadow"
  381.     local.ent leash 10000
  382.     local.ent exec global/enable_ai.scr
  383.     local.ent exec global/setdeathanim.scr NIL
  384.     if (level.script == "maps/m1l3b.scr")
  385.     {
  386.         local.ent accuracy 30
  387.     }
  388. end
  389.  
  390. truck_INIT:
  391.     self takedamage
  392.     self solid
  393.     self removeondeath 0
  394.     
  395.     if (self.nolights == 1)
  396.         self vehicleanim idlenolights
  397.     else
  398.         self vehicleanim idlelights
  399.     if (self.target)
  400.     {
  401.         self.collisionent = self.target
  402.         //self.collisionent hide
  403.     }
  404. end
  405.  
  406. truck_killed local.type:
  407.     self show
  408.     
  409.     self playsound explode_truck
  410.     exec global/earthquake.scr .2 4 0 0    
  411.     local.explosion1 = spawn script_model model models/fx/fx_truck_explosion.tik
  412.     local.explosion1.origin = self gettagposition "engine1"
  413.     local.explosion1.angles = self gettagangles "engine1"
  414.     local.explosion1 anim start
  415.     local.explosion1 notsolid
  416.  
  417.     wait .4
  418.     
  419.     self playsound explode_truck
  420.     exec global/earthquake.scr .2 4 0 0    
  421.     local.explosion2 = spawn script_model model models/fx/fx_truck_explosion.tik
  422.     local.explosion2.origin = self gettagposition "engine2"
  423.     local.explosion2.angles = self gettagangles "engine2"
  424.     local.explosion2 anim start
  425.     local.explosion2 notsolid
  426.  
  427.     if($player istouching self.collisionent)
  428.     {
  429.         $player normal_damage 100
  430.     }
  431.     
  432.     //radiusdamage self.origin level.bomb_damage level.bomb_explosion_radius
  433.     radiusdamage self.origin 200 200
  434.  
  435. //    if (local.type == "green")
  436. //        self.damaged = thread spawn_damaged models/vehicles/opeltruckgreen_d.tik
  437. //    else
  438. //        self.damaged = thread spawn_damaged models/vehicles/opeltruck_d.tik
  439. //    self hide
  440. //    self notsolid
  441.     self.collisionent disconnect_paths
  442.  
  443.  
  444.     local.name = self
  445.     local.angles = self.angles
  446.     local.origin = self.origin
  447. //    local.brushmodel = self.collisionent.brushmodel
  448. //    self remove
  449.     self hide
  450.     self notsolid
  451. //    local.collision = thread damaged_collision local.angles local.origin local.brushmodel
  452.     if (local.type == "green")
  453.         self.damaged = thread spawn_damaged_new models/vehicles/opeltruckgreen_d.tik local.angles local.origin
  454.     else
  455.         self.damaged = thread spawn_damaged_new models/vehicles/opeltruck_d.tik local.angles local.origin    
  456. //    local.collision disconnect_paths
  457.  
  458.  
  459.     if (level.script == "maps/m1l3b.scr")
  460.     {
  461.         println "z:   in m1l3b. making truck not solid"
  462.         self.collisionent remove
  463.         self.damaged notsolid
  464.         self notsolid
  465.         while (self.done_unloading != 1)
  466.             wait 1
  467.         self.origin = (1952 376 80)
  468.     }
  469.     
  470.     wait 10
  471.     local.explosion1 remove
  472.     local.explosion2 remove
  473. end
  474.  
  475. //*****************************************
  476. enemy_bike_think:
  477.     self rendereffects "-shadow"
  478.     self solid
  479.     self.health = 100
  480.     self takedamage
  481.     self removeondeath 0 
  482.     if (self.target)
  483.     {
  484.         self.collisionent = self.target
  485.         //self.collisionent hide
  486.     }
  487.  
  488. self waittill death    
  489.  
  490.     self show
  491.     self playsound explode_bike
  492.     
  493.     self thread spawn_fx models/fx/fx_truck_explosion.tik
  494.     //radiusdamage self.origin level.bomb_damage level.bomb_explosion_radius
  495.     radiusdamage self.origin 200 200
  496.     local.damaged = thread spawn_damaged models/vehicles/bmwbike_d.tik
  497.     self remove
  498. end
  499.  
  500.  
  501.  
  502.  
  503.  
  504. //**************************************
  505. enemy_half-trak_think:
  506.     self.mg42 = self QueryTurretSlotEntity 0 //mg42 setup
  507.     local.gun = self.mg42
  508.     if ($(self.gunner))
  509.     {
  510.         self AttachPassengerSlot 1 self.gunner //gunner positioning
  511.         self.gunner nodamage
  512.     }
  513.     self rendereffects "-shadow"
  514.     self immune bullet
  515.     self immune fast_bullet
  516.     self immune grenade
  517.     self solid
  518.     self.health = 100
  519.     self takedamage
  520.     self removeondeath 0
  521.     if (self.target)
  522.     {
  523.         self.collisionent = self.target
  524.         //self.collisionent hide
  525.     }
  526.     
  527. self waittill death
  528.     
  529. //    self.collisionent disconnect_paths
  530.     self show
  531.     self playsound explode_tank
  532.     self stop
  533.     if (local.gun)
  534.     {
  535.         self DetachTurretSlot 0
  536.         local.gun stopfiring
  537.         local.gun remove
  538.     }
  539.     if ($(self.gunner))
  540.     {
  541.         self DetachPassengerSlot 1 self.gunner.origin
  542.         self.gunner bedead
  543.         self.gunner hide
  544.         self.gunner notsolid
  545.     }
  546.     exec global/earthquake.scr .2 4 0 0
  547.     //radiusdamage self.origin level.bomb_damage level.bomb_explosion_radius
  548.     radiusdamage self.origin 200 200
  549.     self thread spawn_fx models/fx/fx_tank_explosion.tik
  550. //    local.damaged = thread spawn_damaged models/vehicles/sdkfz_green_d.tik
  551. //    self remove
  552.  
  553.     local.name = self
  554.     local.angles = self.angles
  555.     local.origin = self.origin
  556.     local.brushmodel = self.collisionent.brushmodel
  557.     self hide
  558.     self notsolid
  559.     local.collision = thread damaged_collision local.angles local.origin local.brushmodel
  560.     local.damaged = thread spawn_damaged_new models/vehicles/sdkfz_green_d.tik local.angles local.origin
  561.     local.collision disconnect_paths
  562.     
  563.     wait .5
  564.     if (self)
  565.         self remove
  566. end
  567.  
  568.  
  569. //**************************************
  570. enemy_flak_think:
  571.     self rendereffects "-shadow"
  572.     self solid
  573.     self.health = 100
  574.     self takedamage
  575.     self removeondeath 0 
  576.     if (self.target)
  577.     {
  578.         self.collisionent = self.target
  579.         //self.collisionent hide
  580.     }
  581.  
  582. level waittill spawn
  583.  
  584. while ( (level.playertanktarget == 0) || (level.playertanktarget == NIL) )
  585.     wait 1
  586.  
  587.     if (level.sightdistance == NIL)
  588.         level.sightdistance = 16000
  589.     self setaimtarget level.playertanktarget
  590.     thread enemy_flak_attack
  591.     local.attack_thread = parm.previousthread
  592.  
  593. self waittill death    
  594.     //self stopFiring
  595.     self setaimtarget NULL
  596.     self show
  597.     self playsound explode_flak88 
  598.     local.attack_thread delete    
  599.     //radiusdamage self.origin level.bomb_damage level.bomb_explosion_radius
  600.     radiusdamage self.origin 200 200    
  601.     self thread spawn_fx models/fx/fx_tank_explosion.tik    
  602.     local.damaged = thread spawn_damaged models/statweapons/flak88_d.tik
  603.     self remove
  604. end
  605.  
  606.  
  607.  
  608. enemy_flak_attack:
  609.     while (isAlive self)
  610.     {
  611.         if !(vector_within level.playertanktarget.origin self.origin level.sightdistance)
  612.         {        
  613.         //    println "z:             " self " is not firing because of range"
  614.             wait 1
  615.         }
  616.         else if (!(sighttrace level.playertanktarget.origin (self.origin + (0 0 64)) 1))
  617.         {
  618.         //    println "z:             " self " is not firing because of sight trace"
  619.             wait 1
  620.         }
  621.         else
  622.         {
  623.             println "z:         " self " on target, waitting 3 secs to fire"
  624.             wait 3
  625.             self anim fire
  626.             wait 3
  627.         }
  628.     }
  629. end
  630.  
  631.  
  632.  
  633. //****************************************
  634. enemy_tank_think local.notattacking local.type:
  635.  
  636. level waittill spawn
  637.  
  638.     self.type = local.type
  639.     self rendereffects "-shadow"
  640.     self.start_health = (((randomint 3) + 1) * 400)
  641.     self.health = self.start_health
  642.     self removeondeath 0
  643.     println "z:          self.target " self.target 
  644.     if (self.target)
  645.     {
  646.         self.collisionent = self.target
  647.     //    self.collisionent hide
  648.     }
  649.     self.gun = self QueryTurretSlotEntity 0
  650.     self.gun2 = self QueryTurretSlotEntity 1
  651.     if (self.gun)
  652.         self.gun nodamage
  653.     if (self.gun2)
  654.         self.gun2 nodamage
  655.     if (level.sightdistance == NIL)
  656.         level.sightdistance = 16000
  657.     if (local.notattacking != 1)
  658.     {
  659.         while ( (level.playertanktarget == 0) || (level.playertanktarget == NIL) )
  660.             wait 1
  661.         self.gun setAimTarget level.playertanktarget
  662.         thread enemy_tank_attack_loop self.gun
  663.         self.attack_thread = parm.previousthread
  664.         thread tank_pain self.gun
  665.         self.pain_thread = parm.previousthread
  666.     }
  667.  
  668.     thread tank_stop_if_close
  669.  
  670. self waittill death
  671.     println "z:         " self " is dead. self.start_health: " self.start_health
  672.     thread tank_killed
  673. end
  674.  
  675. tank_stop_if_close:
  676.     while ( (isAlive self) && !(vector_within self.origin $player.origin 450) )
  677.     {
  678.         wait 1
  679.     //    println "z:         tank stop if close: " self " is not close"    
  680.     }
  681.     if !(isAlive self)
  682.         end
  683.     if (self.driving == 1)
  684.         self stop
  685.         println "z:         tank stop if close: " self " is close. stopping."
  686. end
  687.  
  688. tank_killed:
  689.     self playsound explode_tank
  690.     self stop
  691.     self.driving = 0
  692.  
  693.     if (self.attack_thread)
  694.         self.attack_thread delete
  695.     if (self.pain_thread)
  696.         self.pain_thread delete
  697.     println "z:          self.type: " self.type
  698.     switch (self.type)
  699.     {
  700.     case empty_turretless_tiger:
  701.         local.model = models/vehicles/tigertank_wot_d.tik
  702.         break
  703.     case panzer_desert:
  704.         local.model = models/vehicles/panzer_iv_d.tik
  705.         break
  706.     case panzer:
  707.         local.model = models/vehicles/panzer_iv_eud.tik
  708.         local.get_out = 1
  709.         local.anims[0] = panzer_exit_1
  710.         local.anims[1] = panzer_exit_2
  711.         local.anims[2] = panzer_exit_3
  712.         break
  713.     case empty_panzer_desert:
  714.         local.model = models/vehicles/panzer_iv_d.tik
  715.         break
  716.     case empty_tiger:
  717.         local.model = models/vehicles/tigertank_d.tik
  718.         break
  719.     default:
  720.         local.model = models/vehicles/tigertank_d.tik
  721.         local.get_out = 1
  722.         local.anims[0] = tank_exit_1
  723.         local.anims[1] = tank_exit_2
  724.         local.anims[2] = tank_exit_3
  725.         local.anims[3] = tank_exit_4
  726.         break
  727.     }
  728.     self thread spawn_fx models/emitters/explosion_tank.tik
  729.     exec global/earthquake.scr .2 4 0 0
  730.     //radiusdamage self.origin level.bomb_damage level.bomb_explosion_radius
  731.     radiusdamage (self.origin + (0 0 200)) 800 400
  732.     wait .4   //wait for explosion fx to cover up the model swap
  733.     self.gun = self QueryTurretSlotEntity 0
  734.     self.gun2 = self QueryTurretSlotEntity 1
  735.     if (self.gun)
  736.     {
  737.         self DetachTurretSlot 0
  738.         self.gun remove
  739.     }
  740.     if (self.gun2)
  741.     {
  742.         self DetachTurretSlot 1
  743.         self.gun2 remove
  744.     }
  745.     local.name = self
  746.     local.angles = self.angles
  747.     local.origin = self.origin
  748.     local.brushmodel = self.collisionent.brushmodel
  749.     self remove
  750.     local.collision = thread damaged_collision local.angles local.origin local.brushmodel
  751.     local.damaged = thread spawn_damaged_new local.model local.angles local.origin
  752.     local.collision disconnect_paths
  753.     if (local.get_out == 1)
  754.         local.damaged thread tank_guys_get_out local.anims local.name
  755. end
  756.  
  757. tank_guys_get_out local.anims local.name:
  758.     wait 3
  759.     if (self.state != "open")
  760.     self anim open
  761.     wait 1
  762.     //self waittill animdone
  763.     if (self.state != "open")
  764.     {
  765.         self anim open_idle
  766.         self.state = "open"
  767.     }
  768.     
  769.     //insert roberts random sorter here
  770.     exec global/randomorder.scr local.anims
  771.     
  772.     for (local.i = 0; local.i < 4; local.i ++)
  773.     {
  774.         if ((randomint 100) <= 70)
  775.         {
  776.             if (local.anims[local.i]) 
  777.             {
  778.                 waitthread tank_guy_spawn local.anims[local.i] local.name
  779.             }
  780.         }
  781.     }
  782. end
  783.  
  784. tank_guy_spawn local.type local.name:
  785.     println "z:       spawning guy to get out " local.type
  786.  
  787.         local.temp = randomint 3
  788.         if (local.temp == 0)
  789.             local.model_type = human/german_panzer_grenadier
  790.         if (local.temp == 1)
  791.             local.model_type = human/german_panzer_obershutze
  792.         if (local.temp == 2)
  793.             local.model_type = human/german_panzer_tankcommander
  794.  
  795.         local.ent = spawn local.model_type
  796.         local.ent.origin = self gettagposition "tag_start"
  797.         local.ent.angles = self gettagangles "tag_start"
  798.         
  799.         local.ent noticescale 1
  800.         local.ent sight 4500
  801.         local.ent mindist 2024
  802.         local.ent maxdist 2448
  803.         local.ent leash 10000
  804.         
  805.         if (level.dontdropweapons == 1)
  806.             local.ent dontdropweapons
  807.         
  808.         local.ent exec global/disable_ai.scr
  809.         local.ent notsolid
  810.         
  811.     println "z:         starting anim: " local.name " " local.type
  812.         local.ent anim_noclip local.type
  813.         local.ent waittill animdone
  814.     println "z:         ending   anim: " local.name " " local.type
  815.         
  816.         
  817.         if ( (local.type == "tank_exit_2") || (local.type == "panzer_exit_2") )
  818.             local.ent.position = "crawl"
  819.         if ( (local.type == "tank_exit_3") || (local.type == "panzer_exit_3") )
  820.             local.ent.health = 45 
  821.         if (local.type == "tank_exit_4")
  822.         {
  823.             local.ent bedead
  824.             end
  825.         }
  826.         
  827.         wait .4
  828.     println "z:         making solid: " local.name " " local.type
  829.         
  830.         local.ent solid
  831.         
  832.         
  833. //        wait 3
  834.     println "z:         enabling AI: " local.name " " local.type
  835.         
  836.         local.ent exec global/enable_ai.scr
  837.         local.ent attackplayer
  838. end
  839.  
  840.  
  841. tank_pain local.gun:
  842.     local.previoushealth = self.health
  843.     local.timer = 0
  844.     while(isAlive self)
  845.     {
  846.         wait .1
  847.         if ( (isAlive self) && (self.health < local.previoushealth) )
  848.         {
  849.             println "z:         " self " is damaged. self.start_health: " self.start_health
  850.             println "z:         current health: " self.health
  851.             println "z:         " self " is stunned"
  852.             self playsound damage_tank
  853.             self.stunned = 1
  854.             local.gun setAimTarget NULL
  855.             
  856.             if (self.driving == 1)
  857.                 self modifydrive 5 100 256
  858.             if (self.driving_reverse == 1)
  859.                 self modifydrive -5 100 256
  860.             
  861.         //    self.smoke = spawn script_model model "models/emitters/linger_smoke.tik"
  862.             self.smoke = spawn "models/emitters/linger_smoke.tik"
  863.             self.smoke notsolid
  864.             self.smoke anim start
  865.             self.smoke.origin = (self.origin + (0 0 80))
  866.             self.smoke glue self
  867.             local.previoushealth = self.health
  868.             local.timer = 0
  869.         }
  870.         
  871.         
  872.         if (local.timer == 80)
  873.         {
  874.             local.gun setAimTarget level.playertanktarget
  875.             if (self.driving == 1)
  876.                 self modifydrive level.enemytankspeed 30 256
  877.             if (self.driving_reverse == 1)
  878.                 self modifydrive level.enemytankspeed_reverse 30 256
  879.             self.stunned = 0
  880.             println "z:         " self " is no longer stunned"
  881.         }
  882.         local.timer++
  883.     }
  884. end
  885.  
  886. enemy_tank_attack_loop local.gun:    //self is the tank
  887.     while (IsAlive self)
  888.     {
  889.         if (self.stunned == 1)
  890.         {
  891.             println "z:             " self " is not firing because stunned"
  892.             wait 1
  893.         }
  894.         else if !(vector_within level.playertanktarget.origin self.origin level.sightdistance)
  895.         {        
  896.         //    println "z:             " self " is not firing because range"
  897.             wait 1
  898.         }
  899.         else if (!(sighttrace level.playertanktarget.origin local.gun.origin 1))
  900.         {
  901.         //    println "z:             " self " is not firing because sight trace"
  902.             wait 1
  903.         }
  904.         else
  905.         {
  906.             println "z:         " self " on target, waitting 3 secs to fire"
  907.             wait 3
  908.             if (self.stunned != 1)
  909.                 local.gun anim fire
  910.             wait 2
  911.         }
  912.     }    
  913. end
  914.  
  915.  
  916.  
  917.  
  918. //local.collision = thread damaged_collision local.angles local.origin local.brushmodel
  919. //local.damaged = thread spawn_damaged_new local.model local.angles local.origin
  920. //----------------------------------
  921. spawn_damaged local.model:
  922.     local.damaged = spawn script_model model local.model
  923.     local.damaged.origin = self.origin
  924.     local.damaged.angles = self.angles
  925.     local.damaged notsolid
  926. end local.damaged
  927.  
  928. spawn_damaged_new local.model local.angles local.origin:
  929.     local.damaged = spawn script_model model local.model
  930.     local.damaged.origin = local.origin
  931.     local.damaged.angles = local.angles
  932. end local.damaged
  933.  
  934. spawn_fx local.fx:
  935.     local.temp = spawn script_model model local.fx
  936.     local.temp notsolid
  937.     local.temp.origin = self.origin
  938.     local.temp anim start
  939.     local.temp notsolid
  940.     wait 5
  941.     local.temp remove
  942. end
  943.  
  944. damaged_collision local.angles local.origin local.brushmodel:
  945.     local.collision = spawn script_object model local.brushmodel
  946.     local.collision.origin = local.origin
  947.     local.collision.angles = local.angles
  948. end local.collision